use super::*;
use std::process::Command;

fn command(image_path: &str) -> eyre::Result<()> {
    let command: &[&str] = &[
        "-c",
        "xfce4-desktop",
        "-p",
        "/backdrop/screen0/monitoreDP-1/workspace0/last-image",
        "-s",
        image_path,
    ];

    Command::new("xfconf-query")
        .args(command)
        .stdout(io::stdout())
        .stderr(io::stderr())
        .output()?;

    trace!("Change completed !");

    Ok(())
}

pub fn change_wallpaper(_ctx: &Context, image_path: &str) -> eyre::Result<()> {
    command(image_path)?;
    Ok(())
}
